<!--
 * @Description: 清理缓存
 * @Author: DHL
 * @Date: 2022-01-12 13:28:18
 * @LastEditors: DHL
 * @LastEditTime: 2022-11-08 14:18:36
-->
<template>
  <div class="tw-clear-cache-wrapper" @click="handleClearCacheClick">
    <svg-icon icon-class="clear"></svg-icon>
  </div>
</template>

<script setup lang="ts">
  import { ElMessage } from 'element-plus'
  import { useCacheDataStore } from '@/store/modules/cacheData'
  import { useLoginUserStore } from '@/store/modules/loginUser'

  const loginUserStore = useLoginUserStore()

  const cacheDataStore = useCacheDataStore()

  function handleClearCacheClick() {
    if (loginUserStore.devloper) {
      cacheDataStore.refreshCacheDataAction()
    }

    loginUserStore.refreshCache().then((result: any) => {
      if (result.success) {
        ElMessage.success('清理缓存成功')
      } else {
        ElMessage.error('清理缓存失败')
      }
    })
  }
</script>

<style scoped lang="scss">
  .tw-clear-cache-wrapper {
    padding: 0px 10px;

    .svg-icon {
      font-size: 18px;
      font-weight: bold;
    }
  }
</style>
